/*
 * @Author: ziqi jhzq12345678
 * @Date: 2025-01-21 09:19:28
 * @LastEditors: ziqi jhzq12345678
 * @LastEditTime: 2025-01-21 10:08:17
 * @FilePath: /pornhub_app/lib/views/merchant/merchat_top.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pornhub_app/components/image_view.dart';
import 'package:pornhub_app/http/http_service.dart';
import 'package:pornhub_app/model/merchat/merchat_picture.dart';

class MerchatTop extends StatefulWidget {
  const MerchatTop({super.key});

  @override
  State<StatefulWidget> createState() => _MerchatTop();
}

class _MerchatTop extends State<MerchatTop> {
  var imgString = '';

  Future initData() async {
    var resp = await httpInstance.get<MerchatPicture>(
        url: 'info/activity/images',
        queryMap: {
          'type': 2,
        },
        complete: MerchatPicture.fromJson);
    if (resp != null) {
      setState(() {
        imgString = resp.imageUrl ?? '';
      });
    }
  }

  @override
  void initState() {
    initData();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 14.w),
      height: 186.w,
      clipBehavior: Clip.hardEdge,
      decoration: BoxDecoration(borderRadius: BorderRadius.circular(4.w)),
      child: ImageView(src: imgString),
    );
  }
}
